<form id="edit-form" class="form-horizontal col-sm-12" role="form" data-toggle="validator" method="POST" action="">
    {:token()}

    <div class="form-group">
        <div class="alert alert-warning-light no-margin">
            基础信息
        </div>
    </div>

    <div class="form-group">


        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label for="c-number">报价单编号:</label>
                <input id="c-number" data-rule="required" class="form-control" placeholder="请输入报价单编号" name="row[number]"
                       value="{$row.number}"
                       type="text">
            </div>
        </div>

        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label >归属客户:</label>
                <input type="hidden" name="row[customer_id]" data-rule="required" value="{$row.customer_id}" >
                <div class="form-control">
                    <a href="javascript:void(0)" class="select-customer" data-name="row[customer_id]"
                       data-url="qingdongams/customer/customer/index?isselect=1"  >
                        {if condition="$row.customer"}{$row.customer.name}{else/}【请点击选择】{/if}</a>
                </div>
            </div>
        </div>

        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label>客户联系人: </label>
                <input type="hidden" name="row[contacts_id]" data-rule="required"  value="{$row.contacts_id}" >
                <div class="form-control">
                    <a href="javascript:void(0)" class="select-contacts" data-name="row[contacts_id]"
                       data-url="qingdongams/customer/contacts/index?isselect=1"  >
                        {if condition="$row.contacts"}{$row.contacts.name}{else/}【请点击选择】{/if}
                    </a>
                </div>

            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label for="c-quote">公司报价人:</label>
                <input id="c-quote" class="form-control selectpage" autocomplete="false" data-source="qingdongams/department/staff/index"
                       placeholder="请选择公司报价人" name="row[order_staff_id]" value="{$row.order_staff_id}" type="text">
            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label for="c-quote_date">报价时间:</label>
                <input id="c-quote_date" data-rule="required" class="form-control datetimepicker"
                       data-date-format="YYYY-MM-DD" data-use-current="true" placeholder="报价时间"
                       value="{$row.quote_date}" name="row[quote_date]" type="text">
            </div>
        </div>

        <div class="col-xs-12 col-sm-10">
            <div class="form-group col-sm-10">
                <label for="c-clause">特约条款:</label>
                <textarea name="row[clause]" id="c-clause" class="form-control editor" cols="30"
                          rows="5">{$row.clause}</textarea>

            </div>
        </div>

        <div class="col-xs-12 col-sm-12">
            <div class="form-group col-sm-10">
                <label>产品列表:</label>
            </div>
        </div>
        <table class="table table-responsive fieldlist" data-name="row[product]" data-template="testtpl2" data-tag="tr">
            <tr>
                <td>产品名称</td>
                <td>产品单价</td>
                <td>数量</td>
                <td>配置说明</td>
                <td>备注</td>
                <td></td>
            </tr>
            <tr>
                <td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 追加</a></td>
            </tr>
            <textarea name="row[product]" class="form-control hide" cols="30" rows="5">{$row.product|json_encode}</textarea>
        </table>

        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label for="c-discount_money">优惠金额:</label>
                <input id="c-discount_money" data-rule="required" class="form-control"
                       placeholder="请输入优惠金额" name="row[discount_amount]" value="{$row.discount_amount}" type="text">
            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label for="c-quote_amount">产品合计:</label>
                <input id="c-quote_amount" data-rule="required" class="form-control"
                       placeholder="请输入产品合计金额" name="row[quote_amount]" value="{$row.quote_amount}" type="text">
            </div>
        </div>

        <div class="col-xs-12 col-sm-10">
            <div class="form-group col-sm-10">
                <input id="c-is_check" name="row[is_check]" type="hidden"
                       value="{if condition='$row.flow_staff_ids' }1{else/}0{/if}">
                <label>是否需要审核:</label>
                <a href="javascript:;" data-toggle="switcher" class="btn-switcher" data-input-id="c-is_check"
                   data-yes="1" data-no="0">
                    <i class="fa fa-toggle-on text-success {empty name='$row.flow_staff_ids' }fa-flip-horizontal text-gray{/empty} fa-2x"></i>
                </a>
                <div id="c-flow_staff_ids"  {empty name='$row.flow_staff_ids' }style="display: none"{/empty} >
                    {if condition="$flow.status == 1"}

                    <div class="col-xs-12 col-sm-12">
                        <div class="form-group col-sm-10">

                            <blockquote style="padding: 2px 10px;">
                                <p>审核信息 <span class="label label-danger">固定审批流</span></p>
                            </blockquote>

                            {foreach name="$flow.stepList" item="val"}
                            <div class="row">
                                <div class="level">
                                    <span>第{$val.order_id}级</span><br>
                                    {if condition="$val.status == 3"}
                                    <span class="label label-info">发起人主管</span>
                                    {elseif condition="$val.status == 1"/}
                                    <span class="label label-info">{:count($val['stafflist'])}人或签</span>
                                    {else/}
                                    <span class="label label-info">{:count($val['stafflist'])}人并签</span>
                                    {/if}
                                </div>
                                {foreach name="$val.stafflist" item="ves"}
                                <div class="stafflist">
                                    <img src="{$ves.img}" class="img-circle">
                                    {$ves.name}
                                </div>
                                {/foreach}
                            </div>
                            <hr>
                            {/foreach}


                        </div>
                    </div>

                    {else/}

                    <div class="col-xs-12 col-sm-12">
                        <div class="form-group col-sm-8">

                            <blockquote style="padding: 2px 10px;">
                                <p>审核信息 <span class="label label-danger">发起人自选</span></p>
                            </blockquote>
                            <div style="margin-left: 20px">
                                <input data-source="qingdongams/customer/contract/getstaff"
                                       class="form-control selectpage" placeholder="请选择审批人" data-pagination="true" data-page-size="10" name="row[flow_staff_ids]" type="text" value="{$row.flow_staff_ids}"  data-multiple="true">
                            </div>

                        </div>
                    </div>
                    {/if}
                </div>
            </div>
        </div>

        <div class="col-xs-12 col-sm-10">
            <div class="form-group col-sm-10">
                <label>报价凭证:</label>
                <div class="input-group">
                    <input id="c-avatar" class="form-control" placeholder="请上传报价凭证" size="50" name="row[file_ids]" type="text"
                           value="{$row.file_ids}">
                    <div class="input-group-addon no-border no-padding">
                        <span><button type="button" id="plupload-avatar" class="btn btn-danger plupload"
                                      data-input-id="c-avatar"
                                      data-multiple="false" data-preview-id="p-avatar"
                                      data-url="qingdongams/base/upload"><i class="fa fa-upload"></i> 上传</button></span>

                    </div>
                    <span class="msg-box n-right" for="c-avatar"></span>
                </div>
                <ul class="row list-inline plupload-preview" id="p-avatar"></ul>
            </div>
        </div>

        <div class="col-xs-12 col-sm-10">
            <div class="form-group col-sm-10">
                <label for="c-edit_reason">修改备注:</label>
                <textarea name="row[edit_reason]" id="c-edit_reason" class="form-control" cols="10"
                          rows="5"></textarea>

            </div>
        </div>

        <div class="form-group layer-footer">
            <div class="col-xs-12 col-sm-8">
                <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
                <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
            </div>
        </div>
    </div>
</form>

<!--定义模板，模板语法使用Art-Template模板语法-->
<script type="text/html" id="testtpl2">
    <tr class="form-inline">
        <td>
            <input type="hidden" name="row[<%=name%>][<%=index%>][product_id]" value="<%=row['product_id']%>" >
            <div class="form-control" style="width: 90%">

                <a href="javascript:void(0)" class="select-product"
                   data-name="row[<%=name%>][<%=index%>][product_id]"
                   data-url="qingdongams/product/product/index?isselect=1"  >
                    <% if(row['name']){%>
                    <%=row['name']%>
                    <% }else{%>
                    【请点击选择】
                    <% }%>
                </a>

            </div></td>

        <td style="width: 80px">
            <input type="number" name="row[<%=name%>][<%=index%>][price]" style="width: 80px"
                   class="form-control price" value="<%=row['price']%>" placeholder="--"></td>
        <td style="width: 80px"><input type="number" name="row[<%=name%>][<%=index%>][number]" style="width: 80px"
                                       class="form-control number" value="<% if(row['number']){%><%=row['number']%><% }else{%>1<% }%>" ></td>

        <td style="width: 200px">
            <input type="text" name="row[<%=name%>][<%=index%>][config_desc]" style="width: 200px"
                   class="form-control" value="<%=row['config_desc']%>" placeholder="配置说明"></td>
        <td style="width: 100px">
            <input type="text" name="row[<%=name%>][<%=index%>][remarks]" style="width: 100px"
                   class="form-control" value="<%=row['remarks']%>" placeholder="备注"></td>
        <td style="width: 120px"><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></td>
    </tr>
</script>